//tab栏切换
// const tab = document.querySelector('.el-tabs__header')
const tabs = document.querySelectorAll('.el-tabs__item')
const line = document.querySelector('.line')
const pane = document.querySelectorAll('.el-tab-pane')
tabs.forEach((item, index) => {
   item.addEventListener('click', function () {
      document.querySelector('.el-tabs__header .active').classList.remove('active')
      item.classList.add('active')
      line.style.left = item.querySelector('span').offsetLeft + 'px'
      line.style.width = item.querySelector('span').offsetWidth + 'px'
      document.querySelector('.show').classList.remove('show')
      pane[index].classList.add('show')
   })
})
//登录页面
const uname = document.querySelector('[name="phone"]')
const psw = document.querySelector('[name="password"]')
const classs = document.querySelectorAll('.el-form-item__error')
const agree = document.querySelector('#agree')
uname.addEventListener('blur', fn1)
function fn1() {
   if (uname.value !== '') {
      classs[0].style.display = 'none'
      return true
   } else {
      classs[0].style.display = 'block'
      classs[0].innerHTML = '请输入手机号'
   }
}
psw.addEventListener('blur', fn2)
function fn2() {
   if (psw.value === '12345678') {
      classs[1].style.display = 'none'
      return true
   } else {
      // myAlter('密码错误')
      classs[1].style.display = 'block'
      classs[1].innerHTML = '密码错误'
   }
}
agree.addEventListener('blur', fn3)
function fn3() {
   if (agree.checked) {
      classs[2].style.display = 'none'
      return true
   } else {
      classs[2].style.display = 'block'
      classs[2].innerHTML = '请勾选'
   }
}
const btn = document.querySelector('#btn-login')
btn.addEventListener('click', function () {
   if (fn1() && fn2() && fn3()) {
      location.href = 'index.html'
   }
})